Skip to content

feat: Regulatory compliance audit — 20 frameworks, 126 checks, cross-framework mapping#183

Merged
SimplyLiz merged 64 commits intomainfrom
feature/compliance-audit
Mar 27, 2026
Merged

feat: Regulatory compliance audit — 20 frameworks, 126 checks, cross-framework mapping#183
SimplyLiz merged 64 commits intomainfrom
feature/compliance-audit

Conversation

@SimplyLiz
Copy link
Copy Markdown
Owner

Summary

Adds ckb audit compliance --framework=<name> — a regulatory compliance auditing engine that maps static code analysis findings to specific regulation articles/clauses across 20 frameworks. No competing SAST tool provides this direct code-to-regulation mapping with cross-framework enrichment.

20 Frameworks, 126 Checks

Category Frameworks Checks
Privacy GDPR/DSGVO, CCPA/CPRA, ISO 27701 21
AI Governance EU AI Act 8
Security ISO 27001, NIST 800-53, OWASP ASVS 4.0, SOC 2 30
Industry PCI DSS 4.0, HIPAA, DORA, NIS2, FDA 21 CFR Part 11 28
EU Product EU Cyber Resilience Act 6
Supply Chain SBOM/SLSA/EO 14028 5
Safety IEC 61508, ISO 26262, DO-178C 17
Coding Standards MISRA C/C++, IEC 62443 12

Cross-Framework Mapping (Key Differentiator)

A single finding gets enriched with every regulation it violates:

"Deprecated MD5 detected" (ISO 27001 A.8.24)
Also violates: NIST SC-13, PCI DSS 4.2.1, ASVS V6.2.1, NIS2 Art.21, GDPR Art.32, HIPAA §164.312, FDA §11.10

Features

  • Every finding maps to a specific regulation article (Art. 25 GDPR, Req 6.2.4 PCI DSS, §164.312 HIPAA, etc.)
  • Confidence scoring (0.0-1.0) on every finding, filterable with --min-confidence
  • PII/PHI scanner with 80+ patterns including German terms for DSGVO
  • SIL/ASIL/DAL-level-gated thresholds for safety standards
  • Output formats: human, JSON, markdown, SARIF
  • CI mode: --ci --fail-on=error
  • Thread-safe parallel check execution (126 checks run concurrently)

Usage

ckb audit compliance --framework=gdpr
ckb audit compliance --framework=pci-dss,hipaa,soc2
ckb audit compliance --framework=all --min-confidence=0.7
ckb audit compliance --framework=iec61508 --sil-level=3
ckb audit compliance --framework=all --format=json --ci

Test plan

  • go build -o ckb ./cmd/ckb — clean build
  • go test ./internal/compliance/... — scanner tests pass
  • go test ./cmd/ckb/... ./internal/config/... — no regressions
  • ckb audit compliance --framework=all — all 20 frameworks produce findings
  • Cross-framework references enriching 1,248+ findings
  • JSON, markdown, human output formats verified
  • Run against external test repositories with known compliance issues

🤖 Generated with Claude Code

SimplyLiz and others added 15 commits March 22, 2026 16:58
- review_test: TestReviewPR_NoSCIPIndex creates 25-file repo without
  SCIP index, runs review with 6 concurrent checks. Validates the
  tsMu fix in searchWithTreesitter doesn't regress.

- secrets: isDocumentationFile() raises entropy threshold to 4.0 for
  generic_secret/generic_api_key patterns in .md/.txt/.rst files.
  Prose words ("Token tracking") have ~3.0 entropy vs real secrets
  at ~4.5+. TestScanFile_MarkdownProseNotFlagged verifies.

- secrets: TestIsDocumentationFile covers all doc extensions and
  common basenames (README, CHANGELOG, etc.)
- errors.go: Log JSON encode failures in WriteError and WriteJSON
  instead of silently discarding. Headers are already sent so status
  can't change, but the error is now visible in logs. (PR #144)

- handlers_delta.go: Validate Content-Type on delta ingest and validate
  endpoints. Rejects non-JSON content types with 415 before reading
  body. (PR #145)

- handlers_cicd.go: Cap coupling check to 20 files. Each Analyze call
  scans git log independently — N files = N git-log calls. Same cap
  pattern as blast-radius (30) and bug-patterns (20). (PR #143)
fix: Address 3 issues from windup PR analysis
Language detection now searches subdirectories (up to depth 3) for
manifest files like go.mod, package.json, Cargo.toml, etc. This
fixes repos where source code lives in subdirs (e.g., src/cli/go.mod).

- findManifest: walks subdirs to find exact manifest filenames
- FindManifestForLanguage: finds manifest for a specific --lang flag
- Skips example/test/doc/vendor dirs to avoid false detections
- Index command runs indexer from the manifest's directory, not root
- Multiple languages properly detected and reported

Before: ckb index → "Could not detect project language" on ShellAI
After:  ckb index → "Multiple languages detected: Go, TypeScript"
        ckb index --lang go → runs scip-go from src/cli/
- TestDetectLanguage_SubdirectoryManifest: go.mod in src/cli/,
  Cargo.toml in packages/core/, package.json in src/web/, root priority
- TestDetectAllLanguages_MultiLanguageMonorepo: Go+TS, Go+Python,
  single language in subdir
- TestDetectLanguage_SkipsExampleAndTestDirs: manifests in examples/,
  testdata/, docs/ not detected
- TestFindManifestForLanguage: per-language manifest lookup for --lang
- TestFindManifest_DepthAndSkipDirs: depth 2/3/4, root priority,
  vendor/examples/node_modules skipped
Language detection now searches subdirectories (up to depth 3) for
manifest files like go.mod, package.json, Cargo.toml, etc. This
fixes repos where source code lives in subdirs (e.g., src/cli/go.mod).

- findManifest: walks subdirs to find exact manifest filenames
- FindManifestForLanguage: finds manifest for a specific --lang flag
- Skips example/test/doc/vendor dirs to avoid false detections
- Index command runs indexer from the manifest's directory, not root
- Multiple languages properly detected and reported

Before: ckb index → "Could not detect project language" on ShellAI
After:  ckb index → "Multiple languages detected: Go, TypeScript"
        ckb index --lang go → runs scip-go from src/cli/
- TestDetectLanguage_SubdirectoryManifest: go.mod in src/cli/,
  Cargo.toml in packages/core/, package.json in src/web/, root priority
- TestDetectAllLanguages_MultiLanguageMonorepo: Go+TS, Go+Python,
  single language in subdir
- TestDetectLanguage_SkipsExampleAndTestDirs: manifests in examples/,
  testdata/, docs/ not detected
- TestFindManifestForLanguage: per-language manifest lookup for --lang
- TestFindManifest_DepthAndSkipDirs: depth 2/3/4, root priority,
  vendor/examples/node_modules skipped
feat: Monorepo language detection + subdir indexing
1. Coupling age filter: skip co-change gaps where the coupled file
   hasn't been modified in 180+ days. Prevents FPs from test files
   written once and never changed. Uses git log for last-mod date.

2. Cognitive complexity weighting: swap cyclomatic (0.25→0.15) and
   cognitive (0.15→0.25) weights in health score. Cognitive is less
   misleading than cyclomatic for switch statements and similar.

3. Symbol rename detection: filter rename pairs in breaking changes.
   When a removed + added symbol share the same file and kind, it's
   likely a rename, not a breaking API change.

4. Split clustering caps: skip coupling analysis for PRs > 200 files
   (use module clustering only). Merge clusters beyond 20 into one
   bucket. Prevents O(n²) explosion on large PRs.

5. Generated file markers: add protobuf headers, swagger/openapi,
   codegen markers (eslint-disable, @generated, protoc-gen,
   graphql-codegen), minified assets (*.min.js/css).
feat: Address 5 items from external technical review
* fix: reduce false positives in secrets scanner and test gap heuristic

Secrets: add varRefRe pattern to isLikelyFalsePositive() that detects
when the captured "secret" is a variable/attribute reference (e.g.,
self._settings.openai_api_key, config.apiKey, os.environ, process.env,
viper.GetString) rather than a hardcoded literal. Adds 7 test cases.

Test gaps: extend findTestFiles() to check the Python/pytest prefix
convention (test_{name}.ext) in addition to suffix patterns. Also
checks sibling tests/ directory and top-level tests/ directory, which
is the standard Python project layout.

* fix: resolve CI failures — undici vulnerability, review JSON parsing, test coverage

- Override undici to ^6.24.0 in pr-analysis action to fix Trivy security scan
- Suppress logger warnings for all output formats (not just human) so stderr
  doesn't corrupt JSON output when CI redirects 2>&1
- Add tests for filterRenamePairs, varRefRe regex, and doc file entropy threshold

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address 8 code review findings from CKB analysis

- filterRenamePairs: deterministic output via sorted keys, filter both
  sides of rename pairs (not just the "removed" half)
- varRefRe: clarify why partial-capture branches exist alongside the
  anchored dotted-chain branch
- review_coupling: batch fileLastModified into single shell invocation
  instead of O(n) git-log subprocesses
- detect.go: document findManifest lexical ordering behavior
- handlers_delta: clarify Content-Type validation allows missing header
- review_health: fix stale weight comment (15%/25% not 25%/15%), add
  weight-sum and ordering assertion test
- Remove eslint-disable from generated markers (too aggressive — flags
  hand-written files with lint suppressions)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ching (#181)

Three CKB review infrastructure fixes:

1. Generated file marker detection was defined but never called —
   detectGeneratedFile now reads the first 10 lines of files and checks
   for GeneratedMarkers (DO NOT EDIT, @generated, etc.)

2. Add dist/*.js and dist/*.css to default generated patterns so bundled
   output (webpack, ncc, etc.) is automatically excluded from review.

3. Fix matchGlob ** suffix matching — was only checking filepath.Base(),
   now tries all path tail segments so patterns like **/dist/*.js work.

4. After HoldTheLine and dismissal filtering, reconcile check summaries
   with surviving findings. A check that reported "5 new bug patterns"
   but had all findings dropped (on unchanged lines) is now downgraded
   to pass with a note.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…O 27701, IEC 61508)

Introduces `ckb audit compliance --framework=<name>` with 41 checks across
5 regulatory frameworks, each mapping findings to specific regulation
articles/clauses. Fills a gap no existing SAST tool covers — direct code-to-
regulation mapping beyond CWE IDs.

Frameworks and checks:
- GDPR/DSGVO (11): PII detection, PII in logs/errors, weak crypto, plaintext
  storage, consent, retention, deletion, data minimization, transport encryption
- EU AI Act (8): model I/O logging, audit trail, human override, kill switch,
  bias testing, data provenance, version tracking, confidence scores
- ISO 27001:2022 (10): secrets, PII leakage, weak crypto, insecure random,
  SQL injection, path traversal, unsafe deserialization, TLS, CORS, config mgmt
- ISO 27701 (5): consent mechanism, deletion/access/portability endpoints,
  purpose logging
- IEC 61508/SIL (7): goto, recursion, nesting, function size, global state,
  unchecked errors, SIL-gated complexity thresholds

Key design decisions:
- Findings reuse query.ReviewFinding — JSON, SARIF, markdown formatters work
- PII scanner with 80+ patterns incl. German terms, configurable via config
- Confidence scoring (0.0-1.0) on every finding, filterable via --min-confidence
- Parallel check execution via sync.WaitGroup
- Non-PII exclusion list prevents false positives on code identifiers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rewrites the /ckb-review and /review slash commands for minimal LLM
token usage (~3-8k tokens vs ~15-30k previously):

- Early exit: score>=80 + verdict=pass → one-line approval, no source read
- CLI-first: ckb review --compact instead of MCP tool discovery
- Targeted reads: only files with warn/fail findings, not all hotspots
- No drill-down phase: CLI compact output has enough signal
- Terse output: flat issue list instead of multi-section prose
- Anti-patterns list: explicit "don't do this" for token waste

Updated in: embedded constant (setup.go), .claude/commands/review.md,
ADR-001, and review advantages doc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…apping

Adds 15 new regulatory frameworks (126 total checks across 20 frameworks)
and a cross-framework mapping engine that enriches findings with references
to every regulation they violate simultaneously.

New frameworks:
- PCI DSS 4.0 (6 checks): PAN detection, secure coding, auth
- HIPAA (5 checks): PHI detection/logging, audit trail, encryption
- SOC 2 (6 checks): access control, monitoring, change management
- NIST 800-53 Rev 5 (6 checks): access, audit, crypto, input validation
- EU Cyber Resilience Act (6 checks): secure defaults, SBOM, vulnerabilities
- DORA (6 checks): circuit breakers, timeouts, health endpoints, rollback
- NIS2 (5 checks): supply chain, vulnerability handling, crypto
- OWASP ASVS 4.0 (8 checks): auth, session, validation, crypto, TLS
- CCPA/CPRA (5 checks): do-not-sell, sensitive PI, data subject rights
- SBOM/SLSA (5 checks): SBOM generation, lock files, provenance, signing
- MISRA C/C++ (6 checks): goto, dead code, switch, memory, type safety
- ISO 26262 (5 checks): ASIL-gated complexity, recursion, null checks
- DO-178C (5 checks): DAL-gated dead code, complexity, traceability
- FDA 21 CFR Part 11 (5 checks): audit trail, authority, e-signatures
- IEC 62443 (6 checks): default creds, input validation, message auth

Cross-framework mapping (CKB differentiator):
A single "weak crypto" finding now shows: "Also violates: NIST SC-13,
PCI DSS 4.2.1, ASVS V6.2.1, NIS2 Art.21, GDPR Art.32, HIPAA §164.312,
FDA §11.10" — no competing tool provides this structural context.

Thread-safety: Added ScanScope.AnalyzeFileComplexity() mutex wrapper to
prevent tree-sitter parser crashes under parallel check execution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

NFR Tests ✅ 39 unchanged

Comparing PR against main branch (dynamic baseline).

Regressions: 0 ✅

Thresholds: WARN ≥ +5% • FAIL ≥ +10%

All scenarios
Scenario Change Actual (B) Base (B) Time
analyzeChange / large +0.0% 193,169 193,169 921µs
analyzeChange / medium +0.0% 38,575 38,575 327µs
analyzeChange / small +0.0% 4,046 4,046 172µs
analyzeChange / xlarge +0.0% 387,417 387,417 1.504962ms
analyzeImpact / large +0.0% 17,966 17,966 131µs
analyzeImpact / small +0.0% 1,924 1,924 18µs
batchGet / large +0.0% 11,789 11,789 163µs
batchGet / small +0.0% 4,733 4,733 152µs
batchSearch / large +0.0% 90,816 90,816 516µs
batchSearch / medium +0.0% 18,036 18,036 192µs
batchSearch / small +0.0% 3,379 3,379 22µs
explore / large +0.0% 94,262 94,262 687µs
explore / small +0.0% 4,253 4,253 56µs
findReferences / large +0.0% 445,943 445,943 4.777574ms
findReferences / medium +0.0% 44,123 44,123 440µs
findReferences / small +0.0% 4,395 4,395 53µs
getAffectedTests / large +0.0% 7,521 7,521 60µs
getAffectedTests / medium +0.0% 3,110 3,110 31µs
getAffectedTests / small +0.0% 903 903 36µs
getAffectedTests / xlarge +0.0% 14,870 14,870 111µs
getArchitecture / large +0.0% 6,690 6,690 54µs
getArchitecture / small +0.0% 960 960 14µs
getCallGraph / deep +0.0% 15,238 15,238 92µs
getCallGraph / shallow +0.0% 887 887 21µs
getHotspots / large +0.0% 16,748 16,748 159µs
getHotspots / small +0.0% 886 886 15µs
listEntrypoints / large +0.0% 23,798 23,798 166µs
listEntrypoints / small +0.0% 4,795 4,795 44µs
prepareChange / large +0.0% 16,194 16,194 143µs
prepareChange / small +0.0% 2,483 2,483 33µs
searchSymbols / large +0.0% 90,246 90,246 244µs
searchSymbols / medium +0.0% 17,766 17,766 100µs
searchSymbols / small +0.0% 3,588 3,588 63µs
summarizeDiff / large +0.0% 19,939 19,939 172µs
summarizeDiff / small +0.0% 2,133 2,133 27µs
traceUsage / large +0.0% 7,728 7,728 98µs
traceUsage / small +0.0% 725 725 12µs
understand / large +0.0% 460,608 460,608 2.651577ms
understand / small +0.0% 5,555 5,555 160µs

* = new scenario, compared against static baseline

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

🟢 Change Impact Analysis

Metric Value
Risk Level LOW 🟢
Files Changed 157
Symbols Changed 142
Directly Affected 0
Transitively Affected 0

Blast Radius: 0 modules, 0 files, 0 unique callers

📝 Changed Symbols (142)
Symbol File Type Confidence
.claude/commands/audit.md .claude/commands/audit.md added 30%
.claude/commands/review.md .claude/commands/review.md modified 30%
.github/actions/pr-analysis/dist/index.js .github/actions/pr-analysis/dist/index.js modified 30%
.github/actions/pr-analysis/package.json .github/actions/pr-analysis/package.json modified 30%
CHANGELOG.md CHANGELOG.md modified 30%
CLAUDE.md CLAUDE.md modified 30%
cmd/ckb/audit_compliance.go cmd/ckb/audit_compliance.go added 30%
cmd/ckb/daemon.go cmd/ckb/daemon.go modified 30%
cmd/ckb/engine_helper.go cmd/ckb/engine_helper.go modified 30%
cmd/ckb/format_audit_compliance.go cmd/ckb/format_audit_compliance.go added 30%
cmd/ckb/index.go cmd/ckb/index.go modified 30%
cmd/ckb/ps.go cmd/ckb/ps.go modified 30%
cmd/ckb/search.go cmd/ckb/search.go modified 30%
cmd/ckb/setup.go cmd/ckb/setup.go modified 30%
cmd/ckb/status.go cmd/ckb/status.go modified 30%
+127 more

Recommendations

  • ℹ️ coverage: 142 symbols have low mapping confidence. Index may be stale.
    • Action: Run 'ckb index' to refresh the SCIP index

Generated by CKB

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

CKB Analysis

Risk Files +42246 -18620 Modules

🎯 142 changed → 0 affected · 🔥 38 hotspots · 📊 12 complex · 💣 15 blast · 📚 156 stale

Risk factors: Large PR with 166 files • High churn: 60866 lines changed • Touches 38 hotspot(s)

👥 Suggested: @lisa.welsch1985@gmail.com (4%), @talantyyr@gmail.com (4%), @lisa@tastehub.io (3%)

Metric Value
Impact Analysis 142 symbols → 0 affected 🟢
Doc Coverage 8.333333333333332% ⚠️
Complexity 12 violations ⚠️
Coupling 0 gaps
Blast Radius 0 modules, 0 files
Index indexed (0s) 💾
🎯 Change Impact Analysis · 🟢 LOW · 142 changed → 0 affected
Metric Value
Symbols Changed 142
Directly Affected 0
Transitively Affected 0
Modules in Blast Radius 0
Files in Blast Radius 0

Symbols changed in this PR:

Recommendations:

  • ℹ️ 142 symbols have low mapping confidence. Index may be stale.
    • Action: Run 'ckb index' to refresh the SCIP index
💣 Blast radius · 0 symbols · 15 tests · 0 consumers

Tests that may break:

  • internal/compliance/crossmap_test.go
  • internal/compliance/engine_test.go
  • internal/compliance/recommend_test.go
  • internal/compliance/scanner_test.go
  • internal/daemon/server_test.go
  • … and 10 more
🔥 Hotspots · 38 volatile files
File Churn Score
.claude/commands/review.md 10.30
.github/actions/pr-analysis/dist/index.js 16.53
cmd/ckb/setup.go 14.24
docs/features/compliance-audit/checks.md 9.46
docs/features/review/advantages.md 11.28
internal/backends/scip/symbols.go 8.99
internal/compliance/crossmap.go 9.23
internal/compliance/dora/resilience.go 9.03
📦 Modules · 5 at risk
Module Files
🔴 internal/compliance 92
🔴 internal/query 16
🟡 cmd/ckb 9
🟡 internal/mcp 9
🟡 testdata/fixtures 8
📊 Complexity · 12 violations
File Cyclomatic Cognitive
.github/actions/pr-analysis/dist/index.js ⚠️ 4596 ⚠️ 18533
cmd/ckb/audit_compliance.go ⚠️ 22 ⚠️ 43
cmd/ckb/format_audit_compliance.go ⚠️ 19 ⚠️ 47
cmd/ckb/index.go ⚠️ 51 ⚠️ 91
cmd/ckb/setup.go ⚠️ 31 ⚠️ 58
cmd/ckb/status.go ⚠️ 16 ⚠️ 35
internal/api/errors.go 14 ⚠️ 26
internal/api/handlers_cicd.go ⚠️ 20 ⚠️ 36
💡 Quick wins · 10 suggestions
📚 Stale docs · 156 broken references

Generated by CKB · Run details

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 8.51723% with 7379 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/compliance/gdpr/retention.go 0.0% 237 Missing ⚠️
internal/compliance/owaspasvs/validation.go 0.0% 227 Missing ⚠️
internal/mcp/tool_impls_listsymbols.go 0.0% 221 Missing ⚠️
internal/compliance/iec61508/structural.go 0.0% 214 Missing ⚠️
internal/compliance/engine.go 15.6% 209 Missing and 2 partials ⚠️
internal/compliance/euaiact/oversight.go 0.0% 183 Missing ⚠️
internal/compliance/iso27001/secure_dev.go 0.0% 183 Missing ⚠️
internal/compliance/sbom/provenance.go 0.0% 176 Missing ⚠️
internal/compliance/scanner.go 24.4% 172 Missing and 4 partials ⚠️
internal/compliance/iso27701/rights.go 0.0% 150 Missing ⚠️
... and 99 more

❌ Your patch status has failed because the patch coverage (8.5%) is below the target coverage (30.0%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #183     +/-   ##
=======================================
- Coverage   47.8%   43.7%   -4.1%     
=======================================
  Files        395     487     +92     
  Lines      66916   75450   +8534     
=======================================
+ Hits       32046   33045    +999     
- Misses     32611   40092   +7481     
- Partials    2259    2313     +54     
Flag Coverage Δ
unit 43.7% <8.5%> (-4.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

SimplyLiz and others added 2 commits March 24, 2026 14:37
…tion (#184)

Syncs local skill refinements to repo and embedded constant:

- Early exit now requires score>=90 + zero warns + <100 lines + no new
  files (score>=80 was unsafe due to per-check caps hiding warnings)
- Added "CKB's blind spots" section listing what the LLM must catch
  (logic errors, business logic, race conditions, etc.)
- Expanded Phase 2 checklist: race conditions, incomplete refactoring,
  secrets beyond CKB's 26 patterns
- Added anti-patterns: trusting score>=80, skipping new files

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- docs/features/compliance-audit/overview.md: Executive summary with
  market positioning and framework coverage
- docs/features/compliance-audit/checks.md: Complete reference of all
  126 checks across 20 frameworks
- examples/github-actions/compliance-audit.yml: Production-ready GitHub
  Actions workflow with SARIF upload, PR comments, and quality gates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

SimplyLiz and others added 2 commits March 24, 2026 14:45
New slash command for CKB-augmented compliance audit with same design
principles as /ckb-review: CLI-first, early exit, targeted reads,
terse output.

Key features:
- Auto-detect applicable frameworks from repo context
- Deduplicate cross-framework findings (1 code fix ≠ 6 findings)
- LLM focuses on contextual triage: applicability, compensating
  controls, business impact prioritization
- installClaudeCodeSkills() now installs both /ckb-review and /ckb-audit

Three copies synced: ~/.claude/commands/ckb-audit.md,
.claude/commands/audit.md, embedded constant in setup.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three improvements to the bug-patterns review check:

1. checkDiscardedError: Skip calls nested inside argument_list nodes.
   Previously flagged Register(NewFramework()) as "discarded return from
   NewFramework" — the return IS consumed as an argument, not discarded.

2. checkDiscardedError: Suppress standalone .Close() calls. Discarding
   Close() errors on read-only file handles is standard Go convention
   (os.Open for reading). Write-path Close errors are caught by the
   missing-defer-close rule instead.

3. checkMissingDeferClose: Recognize inline varName.Close() as valid
   resource cleanup (not just defer). Also removed NewScanner from
   openFuncs — bufio.Scanner doesn't implement io.Closer.

Also adds compliance.ScanFileLines helper for proper open/defer-close
lifecycle in file scanning checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

SimplyLiz and others added 2 commits March 25, 2026 08:46
Found via /ckb-review dogfood on PR #183:

1. Fix 59 file handle leaks across 33 compliance check files — manual
   f.Close() at loop end was skipped on early return via ctx.Err() or
   break. Wrapped in closures with defer f.Close().

2. Add concurrency semaphore to compliance engine — 126 goroutines
   launching simultaneously could exhaust file descriptors. Now capped
   at GOMAXPROCS*4 (max 32).

3. Fix err shadow in installClaudeCodeSkills — `:=` inside loop
   shadowed outer err. Renamed to readErr/writeErr.

4. Fix crossmap dedup — strings.Contains on ruleID caused substring
   collisions (e.g., "nis2" matching "nis"). Now uses exact prefix
   match on slash-delimited ruleID.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dogfooded on PR #183 (compliance audit). Changes:

- Remove --compact flag reference (doesn't exist on CLI)
- Add new file strategy: "read entry point + types first, then follow
  refs" for large new packages (90 new files was untractable otherwise)
- Add "resource leaks" to blind spots list (found the main bug class)
- Update check count 15 → 20
- Add anti-pattern: reading every file in a large new package
- Add parse instructions for JSON output (pipe through python/jq)
- All 3 copies synced: local, repo, embedded constant

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

Dogfooded ckb audit compliance on CKB itself — 281 findings, mostly FPs.

PII scanner:
- Skip "fingerprint" unless paired with "biometric"/"user_fingerprint"
  (in code contexts fingerprint = hash, not biometric data)
- Skip "display_name" (UI labels, not PII)
- Skip test files in CheckPIIInLogs (test assertions reference PII names)

SQL injection (iso27001 + owasp-asvs):
- Skip test files and testdata/fixtures directories
- Skip regex pattern definitions (compliance check code itself)
- Skip lines with parameterized query markers (?, $1)

Results: 281→159 findings, 189→88 unique locations, 0 test file FPs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

Daemon API endpoints (7 stubs → real implementations):
- handleScheduleList: returns schedules from scheduler.ListSchedules()
- handleJobsList: returns active jobs from scheduler state
- handleJobsRoute: GET job details, DELETE to cancel/disable
- handleReposList: loads repo registry via repos.LoadRegistry()
- handleReposRoute: GET repo details by name
- handleFederationsList: lists federations via federation.List()
- handleFederationsRoute: GET federation config by name

CLI daemon status: HTTP health query to localhost:{port}/health with
version, uptime, and per-check status display.

Query engine stubs (4 → real implementations):
- Ownership refresh: parses CODEOWNERS + git-blame via ownership module
- Hotspot refresh: queries git adapter for churn data (90-day window)
- Responsibility refresh: extracts module responsibilities via extractor
- Ownership history: queries ownership_history table from storage

TEMP pattern fix: Split todoPattern into case-insensitive (TODO/FIXME/
HACK/XXX) and case-sensitive (TEMP uppercase only) to stop matching
"temp file", "temp directory" in descriptive comments.

Compliance audit: 48/100 → 97/100 | 105 → 1 finding (unsigned-commits)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

…rmup

Four features for ArchReview SRP pipeline optimization:

1. searchSymbols now returns lines, cyclomatic, cognitive per symbol.
   The enrichWithBodyRanges step now also extracts complexity via
   tree-sitter analyzer, merging body ranges and metrics in one pass.
   Eliminates the enrichment phase — consumers get full symbol data
   in a single searchSymbols call.

2. listSymbols — dedicated bulk listing without search query. Params:
   scope (path prefix), kinds, minLines, minComplexity, sortBy
   (complexity/lines/name), limit (max 200). Returns complete symbol
   inventory with body ranges and complexity. One call replaces
   exploring 40 files one-by-one.

3. getSymbolGraph — batch call graph for multiple symbols. Params:
   symbolIds (max 30), depth (1-3), direction. Returns deduplicated
   nodes and edges across all requested symbols. One call replaces
   30 serial getCallGraph calls.

4. Warm searchSymbols on connect — MCP server fires a background
   searchSymbols("", limit=1) on engine initialization to pre-warm
   the FTS index and cache. First real search call hits warm cache
   instead of cold start.

Both new tools added to refactor preset (now 37 tools).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

searchSymbols: Add minLines, minComplexity, excludePatterns params.
Filtering happens after tree-sitter enrichment so it operates on real
body sizes and complexity values. Eliminates client-side filtering of
80% of results (struct fields, tiny getters, anonymous symbols).

Example: searchSymbols(query:'Review', minLines:30, excludePatterns:['#'])
returns only substantial functions — no Class#member properties.

batchGet: Add includeCounts param. When true, populates referenceCount,
callerCount, calleeCount per symbol via SCIP lookups. Consumers get
fan-in/fan-out metrics without transferring full caller/callee lists.

Example: batchGet(symbolIds:[...], includeCounts:true) returns
{referenceCount:8, callerCount:2, calleeCount:0} per symbol.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

1. FTS empty query bug: FTS Search() returned [] for query="" (line 237:
   "if query == '' return empty"). Added listAll() method that queries
   the symbols_fts_content table directly when query is empty. This is
   the path listSymbols and searchSymbols("") take.

2. Warmup caching bug: MCP server warmup fired SearchSymbols("", limit=1)
   before SCIP index was fully loaded. The empty result got cached, and
   all subsequent empty-query searches returned the cached 0 results.
   Fix: warmup now calls RefreshFTS() instead of SearchSymbols() — this
   populates the FTS table from SCIP data without caching search results.

Before: listSymbols → {symbols:null, totalCount:0} even with fresh SCIP
After:  listSymbols → {symbols:[...], totalCount:15} with complexity data

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

…mous

listSymbols now passes excludePatterns: ["#"] to SearchSymbols, removing
Container#Field properties that SCIP labels as kind=class. These have no
body ranges or complexity data and are noise for behavioral analysis.

Also skips anonymous/unknown/empty symbol names.

Before: 10 symbols, all Class#member with 0 lines/complexity
After:  22 symbols, all functions with real complexity data

For searchSymbols with kinds:['class'], consumers can pass
excludePatterns:['#'] to get only the class itself (e.g., ReviewEngine
220 lines), not its fields (ReviewEngine#ckb 1 line).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

listSymbols/searchSymbols class body ranges: Increased FTS query
multiplier from 2x to 10x when filters (excludePatterns/minLines/
minComplexity) are set. SCIP indexes struct fields as kind=class,
so searching "Daemon" with excludePatterns:["#"] needs 10x headroom
to find the type definition past all the Daemon#field entries.

Before: searchSymbols("Daemon", excludePatterns:["#"]) → 0 results
After:  → Daemon class, lines=22, L28-49

getSymbolGraph with complexity: Each node now includes lines, endLine
(from CallGraphNode location), and cyclomatic/cognitive (from tree-
sitter complexity analysis per file). One getSymbolGraph call now
returns call graph + metrics, replacing getSymbolGraph + batchGet.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

Add .arb (Flutter/ICU localization resource) and .g.dart (Dart generated)
to isCouplingNoiseFile suffixes. Add l10n/ and generated/ to directory
exclusion prefixes.

Flutter's gen-l10n workflow generates app_localizations_*.dart from .arb
source files. These always co-change by definition — flagging them as
"missing co-change partners" when one side is staged produces false
positives, especially with MM git status (staged + further unstaged).

Closes #185

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

Coupling noise filter — added 20+ generated file patterns from research:
- Protobuf/gRPC: .pb.go, .pb.h, .pb.cc, .pb.ts, _grpc.pb.go, _pb2.py
- Go generators: _string.go (stringer), _enumer.go, wire_gen.go, _mock.go
- Dart/Flutter: .freezed.dart, .mocks.dart (in addition to .g.dart/.arb)
- JS/TS bundled: .bundle.js, .chunk.js, .d.ts
- Directories: __generated__/ (GraphQL/Relay), .dart_tool/, __pycache__/

Generated file detection (review) — added matching patterns:
- All protobuf/gRPC extensions across Go, C++, TS, Python
- Go code generators (stringer, mockgen, Wire, enumer)
- Dart/Flutter (freezed, mocks, build_runner)
- GraphQL (__generated__)
- Additional markers: "generated by stringer/mockgen/Wire"

Sources: GitHub Linguist overrides, Dart code generation guide,
Protobuf documentation, Go generate patterns, Swagger/OpenAPI codegen.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

Changelog: comprehensive entry for all v8.3 features — compliance audit
(20 frameworks, --recommend, MCP tool), listSymbols, getSymbolGraph,
searchSymbols enrichment, 42→0 bug-pattern FPs, coupling noise filter,
compliance FP reduction, FTS empty query fix, daemon API implementations.

Fix review issue #1: batchGet IncludeCounts now runs FindReferences +
GetCallGraph in parallel with 10-concurrent semaphore (was sequential).

Fix review issue #3: getSymbolGraph complexity enrichment documents
single-instance analyzer reuse per call.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

gofmt: Reformatted 93 files across internal/compliance/ and 2 other files.

ineffassign (3):
- format_audit_compliance.go: remove dead loc assignment
- do178c/dead_code.go: remove redundant afterTerminator reset
- misra/control_flow.go: same pattern

nilerr (1):
- engine.go:393: return err instead of nil when filepath.Rel fails

unused (4):
- ccpa/sensitive_pi.go: remove useLimitationPatterns
- iec61508/defensive.go: remove uncheckedErrorPatterns + unused regexp import
- iso27001/config_mgmt.go: remove httpPatterns
- sbom/sbom.go: remove sbomCIFiles (replaced by findCIFiles)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

SimplyLiz and others added 3 commits March 27, 2026 16:11
recommend_test.go (4 tests):
- Go project with HTTP+PII → recommends gdpr, nist, owasp
- Empty directory → universal frameworks only
- Deduplication works
- All recommendation fields populated

crossmap_test.go (7 tests):
- Cross-references enrichment for weak-crypto
- Unknown rules leave hint unchanged
- Existing hints preserved with separator
- CWE appended to detail
- GetCrossReferences returns multi-framework refs
- Unknown category returns nil
- ListMappedCategories coverage

engine_test.go (7 tests):
- findSourceFiles with scope, directory exclusion, empty dirs
- isSourceExt for all 18 extensions
- Severity ordering, check filter matching

fts_list_test.go (4 tests):
- listAll returns all symbols for empty query
- Limit respected
- Normal search still works for non-empty query
- Empty database returns empty, not error

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…hints

expandToolset description now lists each preset's key tools and
use cases so the LLM can pick the right one:
- review: PR review, compliance, secrets, test gaps
- refactor: coupling, cycles, dead code, suggestions
- federation: multi-repo, contracts
- docs: documentation, ADRs
- ops: diagnostics, daemon, webhooks

getStatus hints now include preset-awareness: when on core preset,
explicitly suggests expanding to review/refactor/docs with arrows
pointing to the workflows each unlocks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
server_test.go (15 tests): HTTP handler tests via httptest for health,
schedule list, jobs list/route, repos list/route, federations list/route.
Covers nil-scheduler fallback, missing ID validation, method-not-allowed.

symbols_enrich_test.go (6 tests): Post-enrichment filter validation for
excludePatterns (#), minLines, minComplexity, combined filters, no-op.

compound_batch_test.go (3 tests): BatchGetOptions.IncludeCounts field
existence, symbol ID limit, default count behavior.

Total new tests this session: 46 (22 + 24)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

…workflow

- expandToolset: reorder review preset description to lead with
  analyzeTestGaps + getAffectedTests, add 'test coverage analysis'
  to use-case summary
- getStatus hints: explicitly name analyzeTestGaps and getAffectedTests
  in the review preset arrow so LLM connects 'write tests' → review

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

CKB review failed to generate output.

@SimplyLiz SimplyLiz merged commit 1cae8fc into main Mar 27, 2026
13 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant